﻿@model List<OSBIDE.Web.Models.Analytics.ProcedureDataItem>

@using OSBIDE.Web.Helpers

<script src="@Url.Content("~/Scripts/highcharts.js")"></script>
<script src="@Url.Content("~/Scripts/highcharts-more.js")"></script>
<script src="@Url.Content("~/Scripts/exporting.js")"></script>

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

<script type="text/javascript">

    $(document).ready(function () {

        Highcharts.setOptions({
            lang: {
                contextButtonTitle: "Export Commands"
            }
        });

        $('#container').highcharts({

            chart: {
                type: 'bubble',
                zoomType: 'xy'
            },
            title: {
                text: ""
            },
            navigation: {
                menuItemStyle: {
                    padding: "5px",
                    color: '#303030'
                }
            },
            xAxis: {
                title: {
                    enabled: true,
                    text: "EQs"
                },
                startOnTick: true,
                endOnTick: true,
                showLastLabel: true
            },
            yAxis: {
                title: {
                    text: "Grades (%)"
                }
            },
            legend: {
                layout: "vertical",
                align: "right",
                verticalAlign: "top",
                x: -50,
                y: 0,
                floating: true,
                backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || "#FFFFFF",
                borderWidth: 1
            },
            plotOptions: {
                bubble: {
                    dataLabels: {
                        enabled: true,
                        style: { textShadow: 'none' },
                        formatter: function() {
                            return this.point.name;
                        }
                    },
                    minSize: '1%',
                    maxSize: '10%'
                }
            },
            series: [{
                name: "EQ Grades and Counts",
                data: [@Html.Raw(string.Join(",",
                             Model.GroupBy(m => new { m.Score, m.Grade }, (k, g) => new { s=k.Score, g = k.Grade, c=g.Count()})
                                  .Select(m => string.Format("[{0}, {1}, {2}]", m.s, m.g, m.c))))]
            }]

        });
    })

</script>
